package com.igoal.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.compass.annotations.SearchableProperty;

@Entity
@Table(name = "wall_post")
public class UserThought implements Serializable, Audit, PrivacySupport, ItemOwner {

	private static final long serialVersionUID = -2314220432132435298L;

	private Long id;
	private User postOwner;
	private User wallOwner;
	private String post;
	private Date createDate;
	private Date updateDate;
	private DataStatus status;
	private PrivacySetting privacy;

	public UserThought() {
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "post_owner", nullable = false)
	public User getPostOwner() {
		return this.postOwner;
	}

	public void setPostOwner(User user) {
		this.postOwner = user;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "wall_owner", nullable = false)
	public User getWallOwner() {
		return this.wallOwner;
	}
	
	public void setWallOwner(User user) {
		this.wallOwner = user;
	}

	@Column(name = "post", nullable = false)
	public String getPost() {
		return this.post;
	}

	public void setPost(String post) {
		this.post = post;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable=false, name="mdate")
	public Date getUpdateDate() {
		return updateDate;
	}
	
	public void setUpdateDate(Date date) {
		updateDate = date;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable=false, name="cdate")
	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date date) {
		createDate = date;
	}

	@Enumerated(EnumType.STRING)
	@Column(nullable=false, name="status")
	@SearchableProperty
	public DataStatus getStatus() {
		return status;
	}

	public void setStatus(DataStatus status) {
		this.status = status;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "privacy")
	public PrivacySetting getPrivacy() {
		return this.privacy;
	}

	public void setPrivacy(PrivacySetting privacy) {
		this.privacy = privacy;
	}

	@Transient
	public User getOwner() {
		return postOwner;
	}
}
